package com.example.towSpringBoot.config;

import com.example.towSpringBoot.interceptor.CheckPermissionInterceptor;
import com.example.towSpringBoot.interceptor.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @author: xinTong
 * @create: 2024-02-15 15:19
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private Interceptor interceptor;
    @Autowired
    private CheckPermissionInterceptor checkPermissionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 1、将拦截器交给mvc管理
        registry.addInterceptor(interceptor)
                // 2、配置拦截规则
                .addPathPatterns("/**")
                // 3、配置排除规则
                .excludePathPatterns("/api/code","/api/login","/api/logout");

        // 1、将拦截器交给mvc管理
        registry.addInterceptor(checkPermissionInterceptor)
                // 2、配置拦截规则
                .addPathPatterns("/**")
                // 3、配置排除规则
                .excludePathPatterns("/api/code","/api/login","/api/logout");
    }
}
